<template>
	<view>
		<u-card padding="16" v-for="(item,index) in dataList" :key="index">
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="12" text-align="left">
							<view class="u-line-1 u-m-t-4 weikaishi2 jinxingzhong" v-if="item.sdtstate != '已送达'">
								<span>{{item.sdtstate}}</span>
							</view>
							<view class="u-line-1 u-m-t-4 weikaishi2 yiwancheng" v-if="item.sdtstate == '已送达'">
								<span>{{item.sdtstate}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class=" u-m-t-4 weikaishi">
								<span>{{item.getUnit}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class=" u-m-t-4 weikaishi4">
								<span>地址：{{item.getLocation}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="" slot="body">
				<view class="wrap">
					<u-row>
						<u-col span="12" text-align="center" v-if="item.sdtstate != '已送达'">
							<view style="height: 600rpx;" class="u-line-1 u-m-t-10" @click="uploadimg(item.id)">
								<u-image width="600rpx" height="600rpx" src="https://z3.ax1x.com/2021/08/03/ficppn.png"></u-image>
							</view>
						</u-col>
						<u-col span="12" text-align="center" v-if="item.sdtstate == '已送达'">
							<view style="height: 600rpx;" class="u-line-1 u-m-t-10" @click="viewImage(item.sdfileId)">
								<u-image width="600rpx" height="600rpx" :src="imgs(item.sdfileId)"></u-image>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="4" text-align="center">
							<view class=" u-m-t-10">
								<span>送达人:{{item.sdusername}}</span>
							</view>
						</u-col>
						<u-col span="8" text-align="center">
							<view class=" u-m-t-10">
								<span>时间:{{item.sdtime}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="foot-butten" slot="foot" v-if="type == '1'">
				<view :class="flex">
					<u-col span="12" text-align="center" v-if="item.sdtstate != '已送达'">
						<view  class="u-m-10 " @click="sijiqianming(item.id)" >
							送达签名
						</view>
					</u-col>
				</view>
			</view>
		</u-card>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
	import config from '../../../config.js'
	import bmap from '../../../static/js/bmap-wx.js'
	export default {
		data() {
			return {
				dataList:[],
				dispatchNumber:'',
				imgList: [],
				type:'1',
				
				BMap:{},
				flex:'',
			}
		},
		onLoad(open) {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif
			this.type = open.type
			this.$http.post('/rest/transportCar/transportReceipt',{
			},{
				params: {
					dispatchNumber:open.dispatchNumber
				},
				header: {
					'Authorization' :uni.getStorageSync('token'),
				}
			}).then(res => {
				this.dataList = res.data.data
			})
			this.dispatchNumber = open.dispatchNumber
			
			// 新建百度地图对象 
			//#ifdef MP-WEIXIN
			this.BMap = new bmap.BMapWX({ 
				ak: 'ESWpVgDaBgDk7KWsgkUkBE6kzAN0BKTa' 
			});
			//#endif
		},
		onShow() {
			this.refresh()
		},
		computed:{
		},
		methods: {
			sijiqianming(id){
				this.$Router.push({
					name: 'transport_reach',
					params: { rid:id},
				})
			},
			imgs(fileId){
				return config.root + 'system/previewa/' + fileId
			},
			viewImage(fileId) {
				let arr = []
				let img = config.root + 'system/previewa/' + fileId
				arr.push(img)
				uni.previewImage({
					urls: arr,
				});
			},
			uploadimg(id){
				if(this.type == '1'){
					this.$Router.push({
						name: 'transport_reach',
						params: { rid:id},
					})
				}
			},
			refresh(){
				uni.showLoading({
					title: '加载中...'
				})
				this.$http.post('/rest/transportCar/transportReceipt',{
				},{
					params: {
						dispatchNumber:this.dispatchNumber
					},
					header: {
						'Authorization' :uni.getStorageSync('token'),
					}
				}).then(res => {
					this.dataList = res.data.data
				})
				uni.hideLoading()
			},
		}
	}
</script>


<style lang="scss">
	
	.u-body-item {
		padding: 20rpx 15rpx;
	}
	.wrap {
		padding: 0rpx 12rpx;
	}

	.u-row {
		margin: 10rpx 2rpx;
	}
	.weikaishi2{
		font-size: 34rpx;
	}
	.baise{
		color: #ffffff;
		font-size: 34rpx;
	}
	.weikaishi3{
		font-size: 30rpx;
	}
	.weikaishi4{
		color: #000000;
		font-size: 24rpx;
	}
	.weikaishi5{
		color: #19be6b;
		font-size: 22rpx;
	}
</style>
